"use server";
import Title from "antd/es/typography/Title";
import { listQuestionBankVoByPageUsingPost } from "@/api/questionBankController";
import QuestionBankList from "@/components/QuestionBankList";
import "./index.css";
import {Divider} from "antd";

/**
 * 题库列表页面
 * @constructor
 */
export default async function BanksPage() {
    let questionBankList = [];
    // 题库数量不多，直接全量获取
    const pageSize = 200;

    try {
        const questionBankRes = await listQuestionBankVoByPageUsingPost({
            pageSize,
            sortField: "createTime",
            sortOrder: "descend",
        });
        questionBankList = questionBankRes.data.records ?? [];
    } catch (e) {
        // @ts-ignore
        console.error("获取题库列表失败，" + e.message);
    }

    return (
        <div id="banksPage" className="banks-page-container">
            <div className="page-header">
                <Title level={2} className="page-title">题库大全</Title>
                <p className="page-subtitle">探索各类题库，提升你的技能水平</p>
            </div>

            <Divider className="page-divider" />

            <QuestionBankList questionBankList={questionBankList} />
        </div>
    );
}
